package com.tanglongan.concurrent._sync;

public class Sync05 {
    public static void main(String[] args) {
        Thread t = new Sync05Thread();
        t.start();
    }
}

class Sync05Service {
    synchronized public void foo1() {
        System.out.println("foo1方法");
        foo2();
    }

    synchronized public void foo2() {
        System.out.println("foo2方法");
        foo3();
    }

    synchronized public void foo3() {
        System.out.println("foo3方法");
    }
}

class Sync05ServiceSon extends Sync05Service {
    synchronized public void foo4() {
        System.out.println("foo4方法");
    }
}

class Sync05Thread extends Thread {
    @Override
    public void run() {
        Sync05ServiceSon service = new Sync05ServiceSon();
        service.foo1();
    }
}